package cn.com.cetccst.datacenter.policy.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;

import java.util.List;

import cn.com.cetccst.datacenter.collection.dao.BaseDao;
import cn.com.cetccst.datacenter.policy.entity.ComplianceRecordEntity;

@Dao
public interface ComplianceRecordDao extends BaseDao<ComplianceRecordEntity> {

    @Query("SELECT DISTINCT date FROM " + ComplianceRecordEntity.TABLE_NAME + " ORDER BY date DESC LIMIT 1")
    LiveData<Long> getLatestDate();
    @Query("SELECT * FROM " + ComplianceRecordEntity.TABLE_NAME + " WHERE date=:date")
    List<ComplianceRecordEntity> getRecordsByDate(long date);

    @Query("DELETE FROM " + ComplianceRecordEntity.TABLE_NAME + " WHERE date =:date")
    void deleteRecordsByDate(long date);
}
